package com.ma.controller;

import com.ma.model.User;
import com.ma.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

//@Controller
@RestController
//@RequestMapping("ts")
public class HelloController {
    @Autowired
    UserService userService;

    /**
     *
     * @RequestMapping("/hello") 处理客户端来着的hello请求
     *
     * @Controller 和 @ResponseBody 可以合并为@RestController
     */
//    @ResponseBody
//    @RequestMapping("/hello")
//    public String hello(){
//        return "Hello World!";
//    }
//    @GetMapping("/hello")
    @PostMapping("/hello")
    public String hello(@RequestParam("phone") String phone){
        User user = userService.findUserAndRoleByPhone(phone);
        System.out.println("name:"+user);
        return user.toString();
    }
}
